<html>
<head>
    <title>Jetty WebSocket Browser -&gt; Server Debug Tool</title>
    <script src="websocket.js" type="text/javascript"></script>
    <link href="main.css" media="all" rel="stylesheet" type="text/css">
</head>
<body>
jetty websocket/browser/javascript -&gt; server debug tool #console
<div id="console"></div>
<div id="buttons">
    <input class="button" id="connect" name="connect" type="submit" value="connect"/>
    <input class="button" disabled="disabled" id="close" name="close" type="submit" value="close"/>
    <input class="button" disabled="disabled" id="info" name="info" type="submit" value="info"/>
    <input class="button" disabled="disabled" id="ping" name="ping" type="submit" value="ping"/>
    <input class="button" disabled="disabled" id="time" name="time" type="submit" value="time"/>
    <input class="button" disabled="disabled" id="many" name="many" type="submit" value="many"/>
    <input class="button" disabled="disabled" id="manythreads" name="many" type="submit" value="manythreads"/>
    <input class="button" disabled="disabled" id="hello" name="hello" type="submit" value="hello"/>
    <input class="button" disabled="disabled" id="there" name="there" type="submit" value="there"/>
    <input class="button" disabled="disabled" id="dump" name="dump" type="submit" value="dump"/>
    <input class="button" disabled="disabled" id="json" name="json" type="submit" value="json"/>
    <input class="button" disabled="disabled" id="send10k" name="send10k" type="submit" value="send10k"/>
    <input class="button" disabled="disabled" id="send100k" name="send100k" type="submit" value="send100k"/>
    <input class="button" disabled="disabled" id="send1000k" name="send1000k" type="submit" value="send1000k"/>
    <input class="button" disabled="disabled" id="send10m" name="send10m" type="submit" value="send10m"/>
</div>
<script type="text/javascript">
    $("connect").onclick = function (event) {
        wstool.connect();
        return false;
    }
    $("close").onclick = function (event) {
        wstool.close();
        return false;
    }
    $("info").onclick = function (event) {
        wstool.write("info:");
        return false;
    }
    $("ping").onclick = function (event) {
        wstool.write("ping:");
        return false;
    }
    $("time").onclick = function (event) {
        wstool.write("time:");
        return false;
    }
    $("many").onclick = function (event) {
        wstool.write("many:15,300");
        return false;
    }
    $("manythreads").onclick = function (event) {
        wstool.write("manythreads:20,25,60");
        return false;
    }
    $("hello").onclick = function (event) {
        wstool.write("Hello");
        return false;
    }
    $("there").onclick = function (event) {
        wstool.write("There");
        return false;
    }
    $("dump").onclick = function (event) {
        wstool.write("dump:");
        return false;
    }
    $("json").onclick = function (event) {
        wstool.write("[{\"channel\":\"/meta/subscribe\",\"subscription\":\"/chat/demo\",\"id\":\"2\",\"clientId\":\"81dwnxwbgs0h0bq8968b0a0gyl\",\"timestamp\":\"Thu,"
            + " 12 Sep 2013 19:42:30 GMT\"},{\"channel\":\"/meta/subscribe\",\"subscription\":\"/members/demo\",\"id\":\"3\",\"clientId\":\"81dwnxwbgs0h0bq8968b0a0gyl\",\"timestamp\":\"Thu,"
            + " 12 Sep 2013 19:42:30 GMT\"},{\"channel\":\"/chat/demo\",\"data\":{\"user\":\"ch\",\"membership\":\"join\",\"chat\":\"ch"
            + " has joined\"},\"id\":\"4\",\"clientId\":\"81dwnxwbgs0h0bq8968b0a0gyl\",\"timestamp\":\"Thu,"
            + " 12 Sep 2013 19:42:30 GMT\"}]");
        return false;
    }
    $("send10k").onclick = function (event) {
        wstool.write(randomString(10 * 1024));
        return false;
    }
    $("send100k").onclick = function (event) {
        wstool.write(randomString(100 * 1024));
        return false;
    }
    $("send1000k").onclick = function (event) {
        wstool.write(randomString(1000 * 1024));
        return false;
    }
    $("send10m").onclick = function (event) {
        wstool.write(randomString(10 * 1024 * 1024));
        return false;
    }

    function randomString(len, charSet) {
        charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789{}	":;<>,.()[]';
        var randomString = '';
        var charLen = charSet.length;
        for (var i = 0; i < len; i++) {
            var randomPoz = Math.floor(Math.random() * charLen);
            randomString += charSet.substring(randomPoz, randomPoz + 1);
        }
        return randomString;
    }
</script>
</body>
</html>